import request from "@/utils/request";
//添加角色
export const addRolesApi = (data) => {
  return request({
    method: "post",
    url: "roles",
    data,
  });
};

//删除角色
export const delRoleUserApi = (id) => {
  return request({
    method: "DELETE",
    url: `roles/${id}`,
  });
};

// 编辑角色
export const editRoles = (id, data) => {
  return request({
    method: "put",
    url: `roles/${id}`,
    data,
  });
};

//获取单个角色信息
export const getRolesDetail = (id) => {
  return request({
    method: "get",
    url: `roles/${id}`,
  });
};

// 删除角色指定权限
export const delRolesRoot = (id, perId) => {
  return request({
    method: "delete",
    url: `/roles/${id}/rights/${perId}`,
  });
};

//获取权限列表
export const getPerApi = () => {
  return request({
    method: "GET",
    url: "rights/tree",
  });
};

//获取权限列表
export const getPer1Api = () => {
  return request({
    method: "GET",
    url: "rights/list",
  });
};

//获取角色列表
export const getAllUserApi = () => {
  return request({
    method: "GET",
    url: "roles",
  });
};

// 分配权限
export const allotRolesRoot = (id, data) => {
  return request({
    method: "post",
    url: `roles/${id}/rights`,
    data,
  });
};
